package com.jasonli.service.impl;

import com.jasonli.dao.CarDao;
import com.jasonli.domain.Car;
import com.jasonli.service.CarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.xml.ws.Action;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@Service
public class CarServiceImpl implements CarService {

    @Autowired
    private CarDao carDao;

    public boolean save(Car car) {
        car.setOnumber(1);
        car.setMoney(car.getPrice());
        Date d = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String dateNowStr = sdf.format(d);
        car.setOdate(dateNowStr);
        carDao.save(car);
        return true;
    }

    public boolean update(Car car) {
        carDao.update(car);
        return true;
    }

    public boolean delete(Integer chrid) {
        carDao.delete(chrid);
        return true;
    }

    public List<Car> getByCid(Integer cid) {
        return carDao.getByCid(cid);
    }
}
